# -*- coding: utf-8 -*-
import os
from tank.core.documents import Document

# *****************************
# 程序设置
# *****************************

APP_NAME = "wnote"
APP_ROOT = os.path.dirname(os.path.dirname(__file__))
APP_SYSTEM_ERROR_SUBJECT_LINE = APP_NAME + " system error"

# Flask settings
CSRF_ENABLED = True
DEBUG = True

# Flask-User 设置 (https://pythonhosted.org/Flask-User/api.html#config-settings)
USER_APP_NAME = APP_NAME
USER_ENABLE_CHANGE_PASSWORD = True
USER_ENABLE_CHANGE_USERNAME = False
USER_ENABLE_CONFIRM_EMAIL = True
USER_ENABLE_LOGIN_WITHOUT_CONFIRM = False
USER_ENABLE_FORGOT_PASSWORD = True
USER_ENABLE_EMAIL = True
USER_ENABLE_REGISTRATION = True
USER_ENABLE_RETYPE_PASSWORD = True
USER_ENABLE_USERNAME = False
USER_ENABLE_INVITATION = True
SECRET_KEY = '\xb9\x8d\xb5\xc2\xc4Q\xe7\x8ej\xe0\x05\xf3\xa3kp\x99l\xe7\xf2i\x00\xb1-\xcd'
# USER_CHANGE_PASSWORD_TEMPLATE = 'flask_user/change_password.html'
# USER_CHANGE_USERNAME_TEMPLATE = 'flask_user/change_username.html'
# USER_INVITE_ACCEPT_TEMPLATE = 'flask_user/register.html'  # v0.6.2 and up
# USER_MANAGE_EMAILS_TEMPLATE = 'flask_user/manage_emails.html'  # v0.5.1 and up
USER_LOGIN_TEMPLATE = 'pages/login.html'
USER_REGISTER_TEMPLATE = 'pages/register.html'
USER_FORGOT_PASSWORD_TEMPLATE = 'pages/forgot_password.html'
USER_RESET_PASSWORD_TEMPLATE = 'pages/reset_password.html'
USER_INVITE_TEMPLATE = 'pages/invite.html'  # v0.6.2 and up
# USER_RESEND_CONFIRM_EMAIL_TEMPLATE = 'flask_user/resend_confirm_email.html'  # v0.5.0 and up

# USER_AFTER_CHANGE_PASSWORD_ENDPOINT = ''  # v0.5.3 and up
# USER_AFTER_CHANGE_USERNAME_ENDPOINT = ''  # v0.5.3 and up
# USER_AFTER_CONFIRM_ENDPOINT = ''  # v0.5.3 and up
# USER_AFTER_FORGOT_PASSWORD_ENDPOINT = ''  # v0.5.3 and up
USER_AFTER_LOGIN_ENDPOINT = 'home_page'  # v0.5.3 and up
# USER_AFTER_LOGOUT_ENDPOINT = 'user.login'  # v0.5.3 and up
# USER_AFTER_REGISTER_ENDPOINT = ''  # v0.5.3 and up
# USER_AFTER_RESEND_CONFIRM_EMAIL_ENDPOINT = ''  # v0.5.3 and up
# USER_AFTER_RESET_PASSWORD_ENDPOINT = ''  # v0.6 and up
# USER_INVITE_ENDPOINT = ''  # v0.6.2 and up
#
# # Users with an unconfirmed email trying to access a view that has been
# # decorated with @confirm_email_required will be redirected to this endpoint
# USER_UNCONFIRMED_EMAIL_ENDPOINT = 'user.login'  # v0.6 and up
#
# # Unauthenticated users trying to access a view that has been decorated
# # with @login_required or @roles_required will be redirected to this endpoint
# USER_UNAUTHENTICATED_ENDPOINT = 'user.login'  # v0.5.3 and up
#
# # Unauthorized users trying to access a view that has been decorated
# # with @roles_required will be redirected to this endpoint
# USER_UNAUTHORIZED_ENDPOINT = ''  # v0.5.3 and up

# SQLAlchemy 数据库设置 (http://flask-sqlalchemy.pocoo.org)
SQLALCHEMY_TRACK_MODIFICATIONS = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(os.path.join(APP_ROOT, "app.sqlite"))

# MongoDB 设置 (https://flask-pymongo.readthedocs.io/en/latest/)
MONGO_HOST = '127.0.0.1'
MONGO_PORT = '27017'
MONGO_DBNAME = 'wnote'
MONGO_DOCUMENT_CLASS = Document

# Flask Collect (https://github.com/klen/Flask-Collect)
COLLECT_STATIC_ROOT = os.path.join(APP_ROOT, 'static')
COLLECT_STORAGE = 'flask_collect.storage.file'

# Flask-Mail settings (https://pythonhosted.org/Flask-Mail/)
MAIL_USERNAME = 'th_leon@163.com'
MAIL_PASSWORD = 'loveyu0)'
MAIL_DEFAULT_SENDER = '"WNote" <th_leon@163.com>'
MAIL_SERVER = 'smtp.163.com'
MAIL_PORT = 25

ADMINS = [
    '"Admin" <th_leon@163.com>',
]

DISCOVER_PACKAGE = 'ammunition'

# Local
BABEL_DEFAULT_LOCALE = 'zh'

DEFAULT_AVATAR = '/static/images/avatar/default.jpeg'
